    import DataModel from './DateModel'
    export default async (ctx, next) => {
        const start = new Date()
        try {
            await next()
            const ms = new Date() - start
            // console.log(`${ctx.method} ${ctx.url} - ${ms}ms`)
            if (!ctx.body) { // 404
                ctx.body = new DataModel({
                    ...Conf.notFound,
                    code: ctx.status
                }, {
                    method: ctx.method,
                    reqtime: `${ms}ms`
                })
            } else { // 覆写body
                ctx.body = new DataModel(ctx.body, {
                    method: ctx.method,
                    reqtime: `${ms}ms`
                })
            }
        } catch (err) {
            if (err.status === 401) {
                ctx.status = 401;
                // 只返回 JSON 格式的响应
                ctx.body = new DataModel({
                    msg: err.message,
                    code: err.status || ctx.status,
                    data: null
                }, {
                    method: ctx.method,
                    reqtime: `${new Date() - start}ms`
                })
            } else {
                // throw err;
                ctx.app.emit('error', err, ctx)
            }

        }
    }